﻿using BasicInformation.API.Application.Command.OutsourcingCommand;
using BasicInformation.Infrastructure.Interface;
using MediatR;

namespace BasicInformation.API.Application.CommandHandler.OutsourcingCommandHandler
{
    public class OutsourcingDeleteCommandHandler : IRequestHandler<OutsourcingDeleteCommand, int>
    {
        private readonly IOutsourcingRepository outsourcingRepository;

        public OutsourcingDeleteCommandHandler(IOutsourcingRepository outsourcingRepository)
        {
            this.outsourcingRepository = outsourcingRepository;
        }

        public async Task<int> Handle(OutsourcingDeleteCommand request, CancellationToken cancellationToken)
        {
            var info = await outsourcingRepository.Get(request.Id);
            info.IsDel=true;
            return await outsourcingRepository.Update(info);
        }
    }
}
